﻿#region Header

// // <copyright file="Fakes.cs">
// // Copyright (c) 2013, Nicolas Anderlini
// // All rights reserved.
// // 
// // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
// // 
// //     - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// //     - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// //     - Neither the name of Nicolas Anderlini nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
// // 
// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// // </copyright>
// // <author>Nicolas Anderlini</author>
// // <email>nicolas.anderlini@live.fr</email>
// // <date>07-31-2013</date>
// // <summary></summary>

#endregion

namespace Unify.Fake
{

    #region Controllers

    public interface IController
    {
        int FakeMethod();
    }

    [UnifyComponent("Controllers")]
    public abstract class AController : IController
    {
        public virtual dynamic ViewBag
        {
            get { return new object(); }
        }

        public abstract int FakeMethod();
    }

    public class Controller : AController
    {
        public const int RESULT_FAKEMETHOD = 2;
        public IService Service { protected get; set; }

        public override int FakeMethod()
        {
            return RESULT_FAKEMETHOD;
        }
    }

    public class ControllerBis : AController
    {
        public const int RESULT_FAKEMETHOD = 3;
        public IService Service { protected get; set; }

        public IServiceBis ServiceBis { protected get; set; }

        public override int FakeMethod()
        {
            return RESULT_FAKEMETHOD;
        }
    }

    #endregion

    #region Services

    public interface IAService
    {
        int FakeMethod();
    }

    [UnifyComponent("Services", TypeNaming.Classname)]
    public abstract class AService : IAService
    {
        public IDal Dal { protected get; set; }

        public abstract int FakeMethod();
    }

    public interface IService
    {
        bool ServiceMethod();
    }

    public class Service : AService, IService
    {
        public const int RESULT_FAKEMETHOD = 4;

        public bool ServiceMethod()
        {
            return true;
        }

        public override int FakeMethod()
        {
            return RESULT_FAKEMETHOD;
        }
    }

    public interface IServiceBis
    {
        bool ServiceMethodBis();
    }

    public class ServiceBis : AService, IServiceBis
    {
        public const int RESULT_FAKEMETHOD = 5;

        public bool ServiceMethodBis()
        {
            return true;
        }

        public override int FakeMethod()
        {
            return RESULT_FAKEMETHOD;
        }
    }

    #endregion

    #region Dal

    public interface IDal
    {
        int FakeMethod();
    }

    [UnifyComponent("Dal", TypeNaming.None)]
    public class Dal : IDal
    {
        public const int RESULT_FAKEMETHOD = 6;

        public int FakeMethod()
        {
            return RESULT_FAKEMETHOD;
        }
    }

    #endregion

    #region Custom tests

    [UnifyComponent("Lifetime")]
    public class LifetimeTester
    {

    }

    #endregion
}